@extends('shop::layouts.master')
@section('title')
    活动列表
@endsection
@section('tab')
    <div class="x-nav">
            <span class="layui-breadcrumb">
                <a href="">首页</a>
                <a href="">活动管理</a>
                <a><cite>活动列表</cite></a>
            </span>

    </div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5">
                            <div class="layui-input-inline layui-show-xs-block" style="width: 300px;">
                                <input type="text" name="title" placeholder="名称" value="{{$arr_search['title']}}" autocomplete="off" class="layui-input"></div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <select name="type">
                                    <option value="">类型</option>
                                    <option value="1" @if( $arr_search['type'] == 1  ) selected="" @endif >满减</option>
                                    <option value="2" @if( $arr_search['type'] == 2  ) selected="" @endif >促销</option>
                                </select>
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                    <i class="layui-icon">&#xe615;</i>
                                </button>
                                <a class="layui-btn layui-btn-small" onclick="location.reload()" title="刷新">
                                    <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
                                </a>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-body">
                        <button class="layui-btn" onclick="xadmin.open('添加活动','{{route("shop_activity_create")}}')">
                            <i class="layui-icon"></i>添加</button>
                    </div>
                    <div class="layui-card-body layui_overflow_y ">
                        <table class="layui-table layui-form">
                            <thead>
                                <tr>
                                    <th>编号</th>
                                    <th>图片</th>
                                    <th>活动名称</th>
                                    <th>类型</th>
                                    <th>类型列表</th>
                                    <th>活动时间</th>
                                    <th>商品统计</th>
                                    <th>活动状态</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach($data as $key=>$value)
                                <tr class="phono_ine">
                                    <td>{{ $value['id'] }}</td>
                                    <td><img src="{{ $value['img']['full_src'] }}"></td>
                                    <td>{{ $value['title'] }}</td>
                                    <td>{{ $value['type']['type_msg'] }}</td>
                                    <td>
                                        @foreach( $value['activity_extend'] as $vo )
                                             <p>{{$vo}}</p>
                                        @endforeach
                                    </td>
                                    <td>{{ $value['times'] }}</td>
                                    <td>{{ $value['goods_count'] }}</td>
                                    <td>
                                        @if( $value['status']['status']==1 )
                                            {{$value['status']['status_msg']}}
                                            <button title="强制禁用" class="layui-btn layui-btn-xs layui-btn-normal ajax_member_change_status" data-href="{{route('shop_activity_change_status',['id'=>$value['id']])}}" data-title="确定禁用吗？强制禁用后该活动不可恢复。请谨慎操作" href="javascript:;">禁用</button>
                                        @else
                                            {{$value['status']['status_msg']}}
                                        @endif
                                    </td>
                                    <td>
                                        <a title="编辑" class="layui-btn" onclick="xadmin.open('编辑','{{route('shop_activity_goods_create',['id'=>$value['id']])}}',$(window).width(),$(window).height())" href="javascript:;">
                                            添加商品
                                            </a>
                                        <a title="详情" class="layui-btn layui-btn-primary" onclick="xadmin.open('详情','{{route("shop_activity_detail",["id"=>$value["id"]])}}')" href="javascript:;">
                                            查看详情
                                        </a>
                                    </td>
                                </tr>
                                @endforeach
                                @if(empty($data))
                                    <td colspan="66" align="center">暂无数据</td>
                                @endif
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            {{$page_link}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection


@section('tab_js')
        <script>

        layui.use(['form', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

                //列表点击查看大图
                $("body").on('click','.look_img',function(e){
                    layer.photos({
                        photos: '.phono_ine' //格式见API文档手册页
                        ,anim: 1 //0-6的选择，指定弹出图片动画类型，默认随机
                    });
                })
                
                form.on('switch(switchTest)', function(data){
                    var id = $(this).attr('data-id');
                    var status = 1;
                    if( $(this).attr('data-status') == 1 ){
                        status = 2;
                    }
                    $.ajax({
                        url: js_url('shop-banner-update'),
                        type: 'post',
                        data: {id:id,status:status,'_token': '{{csrf_token()}}'},
                        dataType: "json",
                        success: function (result) {
                            if (result.state === 0) {
                                    layer.msg(result.msg, {time: 500, icon: 6}, function () {
                                });
                            } else {
                                layer.msg(result.msg, {time: 2000, icon: 5});
                            }
                        }
                    });
                });

            })
    </script>
@endsection




